You are here: Symbol Reference > Dew Namespace > Dew.Math Namespace > Classes > VectorInt Structure > VectorInt Methods > VectorInt.Diag Method
Dew Math for .NET
ContentsIndexHome
PreviousUpNext
VectorInt.Diag Method

Copies the k-th diagonal from the TMtxInt object.

Syntax
C#
Visual Basic
public TVecInt Diag([In] TMtxInt Mtx, int k);

Copies the k-th diagonal from the TMtxInt object. If k = 0 then the main diagonal is copied, if k < 0 then the subdiagonal is copied and if k > 0 then the k-th super diagonal is copied to the calling vector.

In the following example we setup a matrix, populate it with values and then extract it's main diagonal to a vector.

var a: TVecInt; d: TMtxInt; begin CreateIt(a); CreateIt(d); try // setup matrix d.SetIt(2,2,[1,-2, 3, 4]); // get main diagonal from matrix a.Diag(d,0); // a now containes [1,4]; finally FreeIt(a); FreeIt(d); end; end;
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!